package com.linedata.acq.service;

import java.io.Serializable;
import java.util.List;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.linedata.acq.dao.IDao;

/**
 * Contrat que doit remplir un service par d�faut
 * 
 */
public interface ICommonServiceAsync<T> {

	/**
	 * Get Dao object
	 * 
	 * @param dao
	 */
	public void getDao(AsyncCallback<IDao<T>> callback);

	/**
	 * Return the domain class serviced.
	 * 
	 * @param callback
	 *            the callback to return class The domain class type serviced.
	 */
	public void getType(AsyncCallback<Class<T>> callback);

	/**
	 * Expose the setDao method for testing purposes
	 * 
	 * @param dao
	 */
	public void setDao(IDao<T> _dao, AsyncCallback<Void> callback);

	/**
	 * Generic method used to get a all objects of a particular type.
	 * 
	 * @param callback
	 *            the callback to return List of populated objects
	 */
	public void fetch(AsyncCallback<List<T>> callback);

	/**
	 * Generic method used to get total count. Should be used in sequence with
	 * findAll.
	 * 
	 * @param callback
	 *            the callback to return int number of object found
	 */
	public void count(AsyncCallback<Integer> callback);

	/**
	 * Generic method to get an object based on an identifier.
	 * 
	 * @param id
	 *            the identifier (primary key) of the class
	 * @param callback
	 *            the callback to return a populated object
	 */
	public void findById(Serializable _id, AsyncCallback<T> callback);

	/**
	 * Generic method to save an object.
	 * 
	 * @param o
	 *            the object to save
	 * @param callback
	 *            the callback to return the object created
	 */
	public void add(T _o, AsyncCallback<T> callback);

	/**
	 * Generic method to update an object.
	 * 
	 * @param o
	 *            the object to save
	 * @param callback
	 *            the callback to return the object updated
	 */
	public void save(T _o, AsyncCallback<T> callback);

	/**
	 * Generic method to delete an object based on id
	 * 
	 * @param id
	 *            the identifier
	 */
	public void remove(T _id, AsyncCallback<Void> callback);

	/**
	 * Return a restricted list from startPosition to startPosition+nbElements
	 * and ordered by orderBy
	 * 
	 * restriction : only one orderby is allowed
	 * 
	 * @param startPosition
	 * @param nbElements
	 * @param orderBy
	 * @param orderSens
	 * @param callback
	 *            the callback to return a restricted list of results
	 */
	public void findRestrictedList(int startPosition, int nbElements, String orderBy, String orderSens,
			AsyncCallback<List<T>> callback);

	public void getListeControlByObject(T objet, AsyncCallback<List<T>> callback);
	
	public void AfficherLibelle(int id, AsyncCallback<List<T>> callback);

}